#include "operand.h"

Operand::Operand(OperandType type, int value, string name)
{
	this->type = type;
	this->value = value;
	this->name = name;
	this->prevValue = value;
}

void Operand::SetValue( int value ) 
{ 
	this->value = value;
	this->UpdateState();
}

void Operand::UpdateState()
{
	if ( this->prevValue < this->value ) this->SetState(STATE_POSEDGE);
	else if ( this->prevValue == this->value ) this->SetState(STATE_REGULAR);
	else if ( this->prevValue > this->value ) this->SetState(STATE_NEGEDGE);
	this->prevValue = this->value;
}
